/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FrmQuanLyTuoi.java
 *
 * Created on Dec 16, 2011, 3:50:09 PM
 */
package GUI;

import DAO.Connect;
import DatabaseAccess.quanlyTuoi;
import java.sql.Statement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Vector;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Dell
 */
public class FrmQuanLyTuoi extends javax.swing.JFrame {
   DefaultTableModel model;
    Connection conn;
    Statement st;
    PreparedStatement pstmt;
    ResultSet rs;
    public static String AgeIDD,AgeIDE,AgeID,AgeGroupID;
    quanlyTuoi nhap = new quanlyTuoi();
    Connect connect = new Connect();
    /** Creates new form FrmQuanLyTuoi */
    public FrmQuanLyTuoi() {
        initComponents();
        model = (DefaultTableModel)tblAgeGroup.getModel();
        nhap.Load(tblAgeGroup);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane7 = new javax.swing.JScrollPane();
        tblAgeGroup = new javax.swing.JTable();
        btnDetailAgeGroup = new javax.swing.JButton();
        btnAddAgeGroup = new javax.swing.JButton();
        btnEditAgeGroup = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        tblAgeGroup.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Age Group ID", "Age Group", "Fees"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.Float.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane7.setViewportView(tblAgeGroup);

        btnDetailAgeGroup.setText("Detail");
        btnDetailAgeGroup.setPreferredSize(new java.awt.Dimension(59, 31));
        btnDetailAgeGroup.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDetailAgeGroupActionPerformed(evt);
            }
        });

        btnAddAgeGroup.setText("Add");
        btnAddAgeGroup.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddAgeGroupActionPerformed(evt);
            }
        });

        btnEditAgeGroup.setText("Edit");
        btnEditAgeGroup.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditAgeGroupActionPerformed(evt);
            }
        });

        jLabel1.setText("Quản lý độ tuổi");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(190, 190, 190)
                        .addComponent(jLabel1))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 511, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(78, 78, 78)
                        .addComponent(btnDetailAgeGroup, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnAddAgeGroup, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnEditAgeGroup, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(54, 54, 54)
                .addComponent(jLabel1)
                .addGap(40, 40, 40)
                .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(36, 36, 36)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnAddAgeGroup)
                            .addComponent(btnEditAgeGroup, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(46, 46, 46)
                        .addComponent(btnDetailAgeGroup, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(47, Short.MAX_VALUE))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-547)/2, (screenSize.height-420)/2, 547, 420);
    }// </editor-fold>//GEN-END:initComponents

private void btnDetailAgeGroupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDetailAgeGroupActionPerformed
        int n= tblAgeGroup.getSelectedRow();
        if(n==-1)
        {
            JOptionPane.showMessageDialog(this,"Choose a Class to View");
            return;
        }

          // Vector temp;
//           inittableAgeGroup(tblAgeGroup);
//           temp = (Vector) InitTable.vtData.get(n);
 AgeIDD = tblAgeGroup.getValueAt(n, 0).toString();
       // AgeIDD = (String) temp.get(0);
                FrmDetailAgeGroup frmdetailage = new FrmDetailAgeGroup();
        frmdetailage.setVisible(true);
 
}//GEN-LAST:event_btnDetailAgeGroupActionPerformed

private void btnAddAgeGroupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddAgeGroupActionPerformed
//        new frmAddAgeGroup(this,true).setVisible(true);
//        new InitTable().inittableAgeGroup(tblAgeGroup
                frmAddAgeGroup frmaddAge=new frmAddAgeGroup();
                frmaddAge.setVisible(true);
}//GEN-LAST:event_btnAddAgeGroupActionPerformed

private void btnEditAgeGroupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditAgeGroupActionPerformed
        int n= tblAgeGroup.getSelectedRow();
        if(n==-1)
        {
            JOptionPane.showMessageDialog(this,"Choose a AgeGroup to Edit");
            return;
        }

    AgeIDE = tblAgeGroup.getValueAt(n, 0).toString();
    FrmEditAge frmeditage = new FrmEditAge();
    frmeditage.setVisible(true);
}//GEN-LAST:event_btnEditAgeGroupActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FrmQuanLyTuoi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FrmQuanLyTuoi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FrmQuanLyTuoi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FrmQuanLyTuoi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FrmQuanLyTuoi().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAddAgeGroup;
    private javax.swing.JButton btnDetailAgeGroup;
    private javax.swing.JButton btnEditAgeGroup;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JTable tblAgeGroup;
    // End of variables declaration//GEN-END:variables
}
